# 定义函数
def word_frequency(input_string):
    # 将字符串转化为小写,并去除标点符号
    input_string = input_string.lower().replace(","," ").replace("."," ")
    # 将字符串分割
    words = input_string.split()
    # 建立一个空列表
    word_freq = {}

    # 统计单词出现的频率
    for word in words:
        if word in word_freq:
            word_freq[word] += 1
        else:
            word_freq[word] = 1
    
    # 将单词出现的频率按照高低顺序排序，如果频率一样则按照字典序排序
    sorted_word_freq = sorted(word_freq.items(),key=lambda x:(-x[1],x[0]))
    # 输出字典
    return sorted_word_freq

# 输入字符串
input_string="apple,banana,apple,cherry,banana,apple."
# 调用函数
result = word_frequency(input_string)

for word,freq in result:
    print(f"{word}:{freq}")